package com.vf.admin.client.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.miaodong.entity.PaySelect;
import com.vf.admin.miaodong.entity.PayWxSelect;
import com.vf.admin.miaodong.entity.PopupLog;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 */
@Repository
public class PaySelectDao extends BaseDao<PaySelectDao> {
    public List<PaySelect> list() {
        ArrayList<Object> paramList = new ArrayList<>();
        StringBuilder sbStr = new StringBuilder("select * from pay_select");
        String sql = sbStr.toString();
        return this.queryList(sql, paramList, PaySelect.class);
    }

    public List<PaySelect> wxList() {
        ArrayList<Object> paramList = new ArrayList<>();
        StringBuilder sbStr = new StringBuilder("select * from pay_wx_select");
        String sql = sbStr.toString();
        return this.queryList(sql, paramList, PaySelect.class);
    }


    public void openAlipay(String id) {
        List<Object> paramList = new ArrayList<>();
        StringBuilder sbStr = new StringBuilder("update pay_select set weight = 0");
        this.update(sbStr.toString(), paramList);

        StringBuilder sbStr2 = new StringBuilder("update pay_select set weight=100 where id = "+id);
        this.update(sbStr2.toString(), paramList);
    }

    public void openWx(String id) {
        List<Object> paramList = new ArrayList<>();
        StringBuilder sbStr = new StringBuilder("update pay_wx_select set weight = 0");
        this.update(sbStr.toString(), paramList);
        StringBuilder sbStr2 = new StringBuilder("update pay_wx_select set weight=100 where id = "+id);
        this.update(sbStr2.toString(), paramList);
    }
}
